<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<html>
<head>
<sj:head jqueryui="true" jquerytheme="redmond"></sj:head>
<script type="text/javascript">
	var $tabs = $('#remotetabs').tabs();
	function load()
	{
		alert(document.getElementById('mode').value);
		if(document.getElementById('mode').value =='Amend'){
			$('#remotetabs').tabs('enable',0);
			$('#remotetabs').tabs('enable',1);
			$('#remotetabs').tabs('enable',2);
		}
		else{
			$('#remotetabs').tabs('enable',3);
			$('#remotetabs').tabs('enable',4);
			$('#remotetabs').tabs('enable',5);
			}
	}
	  		
	$.subscribe('rowselectSM', function(event, data) {
	var grid = event.originalEvent.grid;
	var sel_id = grid.jqGrid('getGridParam', 'selrow');
	var isActive = grid.jqGrid('getCell', sel_id, 'status');	
	if(isActive =='false'){
	var r= confirm("Do you want to make this Organisation active?");	
	if(r==true){
		window.location = "vUpdateSupportingMaterial.action";
		}
	else{
		
		}
	}
	else{
		window.location = "vAmendSupportingMaterial.action";
		}
	});  

	$.subscribe('rowselectDirectorate', function(event, data) {
		var grid = event.originalEvent.grid;
		var sel_id = grid.jqGrid('getGridParam', 'selrow');
		var isActive = grid.jqGrid('getCell', sel_id, 'status');	
		if(isActive =='false'){
		var r= confirm("Do you want to make this Organisation active?");	
		if(r==true){
			window.location = "vUpdateDirectorate.action";
			}
		else{
			
			}
		}
		else{
			window.location = "vAmendDirectorate.action";
			}
		});  
		
	function checkPostCode(){
		window.location= "vCheckPostCode.action";
		}
	
	function onClickInterest(){
		
		$('#remotetabs').tabs('disable',4);
		}
	
	function okButtonDeactive() {
		$("#deactivedialog").dialog("close");
	};
	
	function cancelButtonDeactive() {
		$("#deactivedialog").dialog("close");
	};
	
	function cancelButton() {
		alert('Cancel Button pressed!');
		$('#mybuttondialog').dialog('close');
	};
	
	function onClickSave(){
		window.location="vSaveOrganisation.action";
		}
	
	function onClickCreatSM(){
		window.location="vCreatSupportingMaterial.action";
		}
	function onClickCreatBU(){
		window.location="vCreatDirectorate";
		}
	function onClickBack(){
		window.location="vBackOrganisation.action";
		}
	

</script>
</head>
<body onload="load()">
	
	<center><h3><font color="blue">Organisation Details</font></h3></center>
	<s:url id="detail1" action="vDetail1"/>
	<s:url id="detail2" action="vDetail2"/>
	<s:url id="detail3" action="vDetail3"/>
	<s:url id="detail4" action="vDetail4"/>
	<s:url id="detail5" action="vDetail5"/>
	<s:url id="detail6" action="vDetail6"/>
	<sj:dialog id="deactivedialog"
		buttons="{ 
    		'OK':function() { okButtonDeactive(); },
    		'Cancel':function() { cancelButtonDeactive(); } 
    		}"
    	effect="true"
    	showEffect="drop" 
    	autoOpen="false" modal="true" title="Note">
     Do you want to mark this Organiastion in-active?
    </sj:dialog>
	<s:form action="organisationDetail4Actions" theme="simple">
	<input type="hidden" id="mode" name="mode" value="mode">
		<table >
			<tr>
				<td> <sj:a button="true" id="deactiveButton" openDialog="deactivedialog" >Deactive</sj:a> </td>
				<td> <sj:a button="true" onclick="onClickSave()" >Save</sj:a> </td>
				<td> <sj:a button="true" onclick="onClickBack()" >Back</sj:a> </td>
				
				</tr>
		</table>
		<fieldset>
			<sj:tabbedpanel id="remotetabs" spinner="Please wait ..."
				disabledTabs="[0,1,2,3,4,5]" 
				animate="true"
				selectedTab="3"
				onCompleteTopics="tabcomplete"
				onChangeTopics="tabchange">
				<sj:tab id="tab1" href="%{detail1}" label="Detail 1" />
				<sj:tab id="tab2" href="%{detail2}" label="Detail 2" />
				<sj:tab id="tab3" href="%{detail3}" label="Detail 3" />
				<sj:tab id="tab4" href="%{detail4}" label="Detail 4" />
				<sj:tab id="tab5" href="%{detail5}" label="Detail 5" />
				<sj:tab id="tab6" href="%{detail6}" label="BU/Directorate" />
			</sj:tabbedpanel>
		</fieldset>
	</s:form>
</body>
</html>